package boni.JSON;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.widget.Toast;

public class Kontrolni{
	Context myContext;
	
	public Kontrolni(Activity mojActivity){
		
		myContext = mojActivity.getApplicationContext();
		
	}
	public Kontrolni(Context mojContext){
		
		myContext = mojContext;
		
	}

    public boolean checkInternetConnection() {
    	
        ConnectivityManager cm = (ConnectivityManager) myContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        // test for connection
        if (cm.getActiveNetworkInfo() != null
                && cm.getActiveNetworkInfo().isAvailable()
                && cm.getActiveNetworkInfo().isConnected()) {
            return true;
        } else {
            return false;
        }
    }
    
    public void showToast(String tekst){
		int duration = Toast.LENGTH_LONG;

		Toast toast = Toast.makeText(myContext, tekst, duration);
		toast.show();
		
	}
}
